﻿$(function () {
    $("#searchBox").autocomplete(
    {
        source: function (request, response) {
            $.ajax(
            {
                url: "/search/findkeywords", type: "POST", dataType: "json",
                data: { searchText: request.term, maxResults: 10 },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item, value: item, id: item }
                            }
                    ))
                }
            })
        }
    });
});

/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <http://mathiasbynens.be/> */
jQuery(function ($) {
    $.datepicker.regional['nl'] = {
        closeText: 'Sluiten',
        prevText: '←',
        nextText: '→',
        currentText: 'Vandaag',
        monthNames: ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni',
            'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'],
        monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
            'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
        dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
        dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
        dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
        weekHeader: 'Wk',
        dateFormat: 'dd-mm-yy',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: ''
    };
    $.datepicker.setDefaults($.datepicker.regional['nl']);
});

$(document).ready(function () {
    var selected = null;

    var blok5open = false;

    $('#fromDate').datepicker({ beforeShowDay: function (date) {
        if (selected != null && date.getTime() > selected.getTime() &&
                    (date.getTime() - selected.getTime()) < 12 * 24 * 3600 * 1000) {
            return [true, "highlighted"];
        }
        return [true, ""];
    }
    });

    $('#toDate').datepicker({ beforeShowDay: function (date) {
        if (selected != null && date.getTime() > selected.getTime() &&
                    (date.getTime() - selected.getTime()) < 12 * 24 * 3600 * 1000) {
            return [true, "highlighted"];
        }
        return [true, ""];
    }
    });

    $(".link1").bind('mouseenter focusin', function () {
        $(".link1").parent().css('display', 'none');
        $("#block1").css('height', $('#moreBlock1').css('height'));
        $("#block1").css('border', '1px solid #000000');
        return false;
    });

    $("#block1").bind('mouseleave focusout', function () {
        $("#block1").css('height', '0px');
        $("#block1").css('border', '0px solid #000000');
        $(".link1").parent().css('display', 'inline');
    });

    $(".link2").bind('mouseenter focusin', function () {
        $(".link2").parent().css('display', 'none');
        $("#block2").css('height', $('#moreBlock2').css('height'));
        $("#block2").css('border', '1px solid #000000');
        return false;
    });

    $("#block2").bind('mouseleave focusout', function () {
        $("#block2").css('height', '0px');
        $("#block2").css('border', '0px solid #000000');
        $(".link2").parent().css('display', 'inline');
    });

    $(".link3").bind('mouseenter focusin', function () {
        $(".link3").parent().css('display', 'none');
        $("#block3").css('height', $('#moreBlock3').css('height'));
        $("#block3").css('border', '1px solid #000000');
        return false;
    });

    $("#block3").bind('mouseleave focusout', function () {
        $("#block3").css('height', '0px');
        $("#block3").css('border', '0px solid #000000');
        $(".link3").parent().css('display', 'inline');
    });

    $(".link4").bind('mouseenter focusin', function () {
        $(".link4").parent().css('display', 'none');
        $("#block4").css('height', $('#moreBlock4').css('height'));
        $("#block4").css('border', '1px solid #000000');
        return false;
    });

    $("#block4").bind('mouseleave focusout', function () {
        $("#block4").css('height', '0px');
        $("#block4").css('border', '0px solid #000000');
        $(".link4").parent().css('display', 'inline');
    });

    $(".link5").bind('mouseenter focusin', function () {
        $(".link5").parent().css('display', 'none');
        if ($('#moreBlock5').css('height') < 300) {
            $("#block5").css('height', $('#moreBlock5').css('height'));
        }
        else {
            $("#block5").css('height', 300);
        }
        $("#block5").css('border', '1px solid #000000');
        return false;
    });
    $("#block5").bind('mouseleave focusout', function () {
        $("#block5").css('height', '0px');
        $("#block5").css('border', '0px solid #000000');
        $(".link5").parent().css('display', 'inline');
    });

    $(".link6").bind('mouseenter focusin', function () {
        $(".link6").parent().css('display', 'none');
        $("#block6").css('height', $('#moreBlock6').css('height'));
        $("#block6").css('border', '1px solid #000000');
        return false;
    });

    $("#block6").bind('mouseleave focusout', function () {
        $("#block6").css('height', '0px');
        $("#block6").css('border', '0px solid #000000');
        $(".link6").parent().css('display', 'inline');
    });

    $(".link7").bind('mouseenter focusin', function () {
        $(".link7").parent().css('display', 'none');
        if ($('#moreBlock7').css('height') < 300) {
            $("#block7").css('height', $('#moreBlock7').css('height'));
        }
        else {
            $("#block7").css('height', 300);
        }
        $("#block7").css('border', '1px solid #000000');
        return false;
    });

    $("#block7").bind('mouseleave focusout', function () {
        $("#block7").css('height', '0px');
        $("#block7").css('border', '0px solid #000000');
        $(".link7").parent().css('display', 'inline');
    });


    /* test does not work? 
        for (i = 1; i <= 7; i++) {
        alert('i=' + i)
        if (i == 5) {
            alert('i=5 ...' + i)
            $(".link" + i).bind('mouseenter focusin', function () {
                $(".link" + i).parent().css('display', 'none');
                if ($('#moreBlock' + i).css('height') < 300) {
                    $("#block" + i).css('height', $('#moreBlock' + i).css('height'));
                }
                else {
                    $("#block" + i).css('height', 300);
                }
                $("#block" + i).css('border', '1px solid #000000');
                return false;
            });
            $("#block" + i).bind('mouseleave focusout', function () {
                $("#querytext").val('leave');
                $("#block" + i).css('height', '0px');
                $("#block" + i).css('border', '0px solid #000000');
                $(".link" + i).parent().css('display', 'inline');
            });
        } else {
            $(".link" + i).bind('mouseenter focusin', function () {
                $(".link" + i).parent().css('display', 'none');
                $("#block" + i).css('height', $('#moreBlock' + i).css('height'));
                $("#block" + i).css('border', '1px solid #000000');
                return false;
            });

            $("#block" + i).mouseleave(function () {
                $("#block" + i).css('height', '0px');
                $("#block" + i).css('border', '0px solid #000000');
                $(".link" + i).parent().css('display', 'inline');
            });
        }
    }
    */

}); 



